One-of is used to randomly select only one agent out of an agentset or a list. It takes the form of one-of agentset/list, for example ask one-of patches [ set pcolor red ] will turn one random patch red. One-of can also randomly select one item from a provided list. For example, ask turtles [set color one-of [ red yellow blue ] ] will change the color of each turtle randomly to either red, yellow, or blue.
If one-of is used on an agentset which has no agents (for example, ask turtles with [color = red] but there are no red turtles), an error will occur. See nobody for how to prevent the error.
Once you mastered the one-of primitive, don't stop there. Check out the resources below to improve your NetLogo skills.
one-of primitive: